<?php
if (! defined ( FLAG )){ trigger_error('Access error!', E_USER_ERROR); die; }

global $STR;
$STR->setVar(array('DATA','title'),'Driver-cmf | Крестики-нолики');
$STR->setVar(array('DATA','main_text'),'');

	$BD = $STR->getVar(array('BD'));

	if (isset($_POST['exit'])) {

		unset($_SESSION['online']);
 		unset($_SESSION['id_gamers']);
		unset($_SESSION['login']);
	
	}	

	if (isset($_POST['enteryForm'])) {

		$post = $_POST['enteryForm'];
		$res = $BD->Query('SELECT DISTINCT * FROM `krestikii-noliki`.`gamers` WHERE login = \''.$post['login'].'\' AND password = \''.md5($post['password']).'\'')->Fetch();

		if ($res != false) {

			$_SESSION['online'] = 1;
 			$_SESSION['id_gamers'] = $res['id'];
			$_SESSION['login'] = $res['login'];

			header("Location: http://localhost/Driver/page/4");
		} else {
			$error[] = 'Неверный логин или пароль';
		}
	}

//var_dump($_POST);
//var_dump($_SESSION);

?>
